package flc.ast.adapter;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.TimeUtils;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.RecordBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.media.bean.AudioBean;

public class RecordAdapter extends StkProviderMultiAdapter<AudioBean> {
    public RecordAdapter() {
        addItemProvider(new RecordItemProvider());
    }

    private class RecordItemProvider extends BaseItemProvider<AudioBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_record;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, AudioBean bean) {
            baseViewHolder.setText(R.id.tvRecordName, bean.getName());
            baseViewHolder.setText(R.id.tvRecordTime, TimeUtils.millis2String(bean.getDateModified() * 1000L, "yyyy-MM-dd HH:mm"));

            if (bean.isSelected()) {
                baseViewHolder.setImageResource(R.id.ivRecordPlay, R.drawable.lyzt1);
            } else {
                baseViewHolder.setImageResource(R.id.ivRecordPlay, R.drawable.lybf1);
            }
        }
    }
}
